package com.thinker.loan.consumer.service.processor;

import com.thinker.loan.consumer.model.LoanApplicationRequest;
import org.springframework.stereotype.Component;

@Component
public class AmountProcessor extends AbstractLoanProcessor {
    @Override
    public void process(LoanApplicationRequest request) {
        // 授信额度 = MIN(月收入×24 - 其他负债, 抵押物估值×70%)
        request.setAmount(Math.min(request.getCustomer().getMonthlyIncome() * 24 - request.getCustomer().getDebtAmount(), request.getCustomer().getMortgageValue() * 0.7));
    }
}
